﻿using System;
using System.Collections.Generic;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EventManager.Model.Entites;

namespace EventManager.Model.Mappings
{
    public class CategoriesMappings : EntityTypeConfiguration<Categories>
    {
        public CategoriesMappings()
        {
            this.HasKey(n => n.Id);
            this.Property(n => n.Name);
            this.Property(n => n.Description);
            this.HasMany(n => n.Events).WithMany(n => n.Categories)
                .Map(n =>
                {
                    n.MapRightKey("EventId");
                    n.MapLeftKey("CategoryId");
                    n.ToTable("EventsCategories");
                });
        }
    }
}
